package data_structure;

import java.awt.List;

/**
 * @author GongChen
 * Cell_list类实现从xls文件读入数据存储至链表结构中
 *
 */
public class NodeList{
	
	private Node first_cell=null;
	private Node last_cell=null;
	private Node now_cell=first_cell;
	private int size=0;
	public int getSize() {
		return size;
	}
	public void setSize(int size) {
		this.size = size;
	}
	public Node getFirst_cell() {
		return first_cell;
	}
	public void setFirst_cell(Node first_cell) {
		this.first_cell = first_cell;
	}
	public Node getNow_cell() {
		return now_cell;
	}
	public void setNow_cell(Node now_cell) {
		this.now_cell = now_cell;
	}
	public Node getLast_cell() {
		return last_cell;
	}
	public void setLast_cell(Node last_cell) {
		this.last_cell = last_cell;
	}
	public void add_cell(Node cell)
	{
		if(this.first_cell==null)
			this.first_cell=this.last_cell=this.now_cell=cell;
		else
		{
			this.last_cell.next=cell;
			this.last_cell=cell;
		}
		this.size+=1;
	}
	public void del_cell(int index)
	{
		Node tmp=this.first_cell;
		if(index==0)
		{
			this.first_cell=this.first_cell.next;
		}
		else
		{
			for(int i=0;i<index-1;i++)
			{
				if(tmp!=null)
					tmp=tmp.next;
			}
			Node del=tmp.next;
			tmp.next=del.next;
		}
		this.size-=1;
	}
	public Node get()
	{
		return this.last_cell;
	}
	public Node get(int index)
	{
		if(index>=this.size)
			return null;
		else
		{
			Node tmp=this.first_cell;
			for(int i=0;i<index;i++)
			{
				tmp=tmp.next;
			}
			return tmp;
		}
	}
}
